package com.unidt.www.server;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.util.concurrent.TimeUnit;

/**
 * 项目的启动类
 *
 * @author 华院计算源码
 */
@Log4j2
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${unidt.info.base-package}
@SpringBootApplication(scanBasePackages = {"${unidt.info.base-package}.server", "${unidt.info.base-package}.module"})
//@SpringBootApplication
public class UnidtServerApplication {

    public static void main(String[] args) {



        ConfigurableApplicationContext application = SpringApplication.run(UnidtServerApplication.class, args);
        Environment env = application.getEnvironment();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");

        ThreadUtil.execute(() -> {
            ThreadUtil.sleep(2, TimeUnit.SECONDS); // 延迟 2 秒，保证输出到结尾
            log.info("\n----------------------------------------------------------\n\t" +
                    "Application workflow is running! Access URLs:\n\t" +
                    "Local: \t\thttp://localhost:" + port + (path!=null?path:"") + "/\n\t" +
                    "API Local: \thttp://localhost:" + port + (path!=null?path:"") + "/doc.html\n\t" +
                    "----------------------------------------------------------");
        });



    }

}
